package com.allianz.webapps.controllers;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.allianz.webapps.https.interfaces.type001.pojo.User;
import com.allianz.webapps.https.interfaces.type002.pojo.AppCreateRequset;
import com.allianz.webapps.https.interfaces.util.HttpsUtil;
import com.allianz.webapps.https.interfaces.util.ObjectUtil;
import com.fasterxml.jackson.databind.ObjectMapper;

//http://localhost:8080/pad_marketing/main/appCreate.action
@Controller
@RequestMapping(value = "main")
public class Type002AppCreateController {
	
	@Autowired
	private ObjectMapper objectMapper;
	@Autowired
	private	ObjectUtil objectUtil;
	
	@RequestMapping(value = "type002appCreate")
	@ResponseBody
	public String appCreate(@RequestParam(value="jsonParam") String jsonParam,HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		AppCreateRequset appCreate = objectMapper.readValue(jsonParam,AppCreateRequset.class);
		HttpSession hs = request.getSession();
		User user = (User) hs.getAttribute("username");
		appCreate.setUser(user);
		String body=objectUtil.requestParam(appCreate, "app.create");
		return body;
	}
}
